package com.ch5;

import java.util.Arrays;

/**
 * @author woldier
 * @version 1.0
 * @description TODO
 * @date 2023/5/16 10:52
 **/
public class People {
    public static void main(String[] args) {
        Bank bank = new Bank();

        Thread t1 = new Thread(()->{
            for (int i = 0; i < 1000; i++) {
                bank.withdraw(2);
            }
        },"t1");
        Thread t2 = new Thread(()->{ for (int i = 0; i < 1000; i++) {
            bank.withdraw(-1);
        }},"t2");

        t1.start();
        t2.start();

        try {
            t1.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        try {
            t2.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println(bank.getValue());


    }
}
